#ifndef INC_MODEL_FRAGMENT_H
#define INC_MODEL_FRAGMENT_H

#include <vector>
#include <string>

// TODO FWD DCL
#include "Atom_Element_Indexer.h"

#include <iostream> // TODO: Borrar

class Atom;

class Fragment
{
    typedef std::vector< const Atom* > Atoms;
    Atoms atoms;
	 std::string name;

public:
    typedef Atoms::const_iterator const_iterator;

    std::string get_sequence(const AtomElementIndexer& atom_element_indexer) const
    {
        std::string seq;
        seq.reserve(20);

        for (Atoms::const_iterator i = atoms.begin(); i != atoms.end(); ++i)
        {
            const Atom* atom = *i;
            const Atom_Element* element = atom_element_indexer.get_element_of(atom);
            seq += element->symbol;
        }

        return seq;
    }

    void add(const Atom* atom)
    {
        atoms.push_back(atom);
    }

	 const std::string& get_name() const
	 {
		 return name;
	 }

	 void set_name(const std::string& name)
	 {
		 this->name = name;
	 }

	 const Atom* locate(const std::string fqn) const
	 {
		  // TODO: Is it worth using a map here?
        for (Atoms::const_iterator i = atoms.begin(); i != atoms.end(); ++i)
        {
            const Atom* atom = *i;
				std::cout << atom->fqn << "\n";
				if (atom->fqn == fqn) return atom;
        }

        return NULL;
	 }
};

#endif /* INC_MODEL_FRAGMENT_H */
